<?php
namespace Kuoqi;
use Kuoqi\Dom\DomDocument;
use Kuoqi\Dom\DomSelector;
/**
 * Class Dom
 * @package Kuoqi
 * dom树相关信息
 */
class Dom{
	
	public $document = null;
	public $actSelector = null;//当前活跃的选择器
	
	public function __construct(){
		$this->document = new DomDocument();	
	}
	
	
	//创建一个Dom树
	public function loadHTML($domString){
		libxml_use_internal_errors(true);
		$imad = mb_detect_encoding ($domString);
		$domString = mb_convert_encoding($domString,'utf-8',$imad);
		$domString = '<?xml encoding="utf-8" ?>'.$domString;
		return $this->document->loadHTML($domString);
	}
	
	//尝试的一个选择器
	public function selector($doms){
		return $actSelector = new DomSelector($doms);
	}
	
	//冲刷内容
	public function flush(){
		return $this->document->saveHTML();	
	}
	
	
}